﻿using System.Collections.Generic;
using System.Data.SqlClient;

namespace Red.Launcher.ViewModels.Workspaces.Database.Sql
{
    public abstract class Query
    {
        #region Private Data

        private List<Record> _parents = new List<Record>();

        #endregion Private Data

        #region Public Properties

        /// <summary>
        /// Used by Transaction to internally group queries together.
        /// </summary>
        /// <remarks>
        /// By default queries are grouped by table. For example, this means that all sql insert objects can be combined into a single sql query statement.
        /// </remarks>
        internal virtual string TransactionId { get { return Table; } }
        public Record Record { get; private set; }
        public string Table { get { return Record.Metadata.Table; } }
        public List<Record> Parents { get { return _parents; } }
        public virtual IEnumerable<SqlParameter> Parameters { get; }

        #endregion Public Properties

        #region Protected Properties

        protected static int ParameterIdPool { get; set; }

        #endregion Protected Properties

        #region C-Tor

        public Query( Record record )
        {
            Record = record;
        }

        #endregion C-Tor
    }
}
